      SUBROUTINE GETLIN ( NREAD, ERROR, LINE, LEN )
C*
C*                  *******************************
C*                  *******************************
C*                  **                           **
C*                  **          GETLIN           **
C*                  **                           **
C*                  *******************************
C*                  *******************************
C*
C*     SUBPROGRAM :
C*          GET LINE
C*
C*     AUTHOR :
C*          ART RAGOSTA
C*          MS 207-5
C*          AMES RESEARCH CENTER
C*          MOFFETT FIELD, CA  94035
C*          (415) 694-5578
C*
C*     PURPOSE :
C*          READ ONE OR MORE LINES OF INPUT, CAPITALIZE, DELETE COMMENTS
C*          AND CONTINUE READING IF CONTINUATION SPECIFIED (...).
C*
C*     INPUT ARGUMENTS :
C*          NREAD - UNIT FROM WHICH TO READ INPUT
C*
C*     OUTPUT ARGUMENTS :
C*          ERROR - AN ERROR WAS ENCOUNTERED DURING INPUT, OR
C*                   INPUT WAS TOO LONG.
C*          LINE  - THE CHARACTER*500 VARIABLE CONTAINING THE LINE.
C*          LEN   - NUMBER OF CHARACTERS RETURNED IN LINE.
C*
C*     INTERNAL WORK AREAS :
C*          STRING - 80 CHARACTER BUFFER FOR READS FROM TERMINAL.
C*
C*     COMMON BLOCKS :
C*          NONE
C*
C*     FILE REFERENCES :
C*          NREAD
C*
C*     DATA BASE ACCESS :
C*          NONE
C*
C*     SUBPROGRAM REFERENCES :
C*          CAPS
C*
C*     ERROR PROCESSING :
C*          THE LINE LENGTH IS NOT ALLOWED TO EXCEED 500 CHARACTERS.
C*
C*     TRANSPORTABILITY LIMITATIONS :
C*          NONE
C*
C*     ASSUMPTIONS AND RESTRICTIONS :
C*          NONE
C*
C*     LANGUAGE AND COMPILER :
C*          ANSI FORTRAN 77
C*
C*     VERSION AND DATE :
C*          VERSION I.0      3-OCT-84
C*
C*     CHANGE HISTORY :
C*           3-OCT-84    INITIAL VERSION
C*
C***********************************************************************
C*
      CHARACTER*500 LINE
      CHARACTER*80 STRING
      LOGICAL ERROR, CONT
C
      ERROR = .FALSE.
      LEN  = 1
      LINE = ' '
      CONT = .TRUE.
C
C --- WHILE CONTINUE FLAG IS SET DO...
C
10    IF ( CONT ) THEN
         READ ( NREAD, 900 )STRING
         CALL CAPS ( STRING )
         DO 20 J = 1,80
C
C ------ EXCLAMATION MEANS REST OF LINE IS COMMENTARY
C
            IF ( STRING(J:J) .EQ. '!' )GO TO 30
            LINE(LEN:LEN) = STRING(J:J)
            LEN = LEN + 1
            IF (LEN .GT. 500) THEN
               ERROR = .TRUE.
               RETURN
            ENDIF
20          CONTINUE
C
C --- NOW REMOVE ANY EXCESSIVE TRAILING BLANKS.
C
30       IF ( LINE(LEN:LEN) .EQ. ' ' ) THEN
            LEN = LEN - 1
            IF ( LEN .GT. 1 ) GO TO 30
         ENDIF
         CONT = .FALSE.
C
C --- CHECK FOR CONTINUATION ( ELLIPSES ).
C
         IF ( LINE(LEN:LEN) .EQ. '.' ) THEN
            I1 = LEN - 1
            IF ( LINE(I1:I1) .EQ. '.' ) THEN
C
C --- ELLIPSES FOUND, REMOVE IT AND SET CONTINUATION FLAG
C
               CONT = .TRUE.
40             LEN = LEN - 1
               IF ((LINE(LEN:LEN) .EQ. '.') .AND. (LEN .GT. 1))
     $          GO TO 40
            ENDIF
C
C --- ADD ONE SPACE AT THE END OF THE LINE
C
            IF (LEN .LT. 499) THEN
               LEN = LEN + 1
               LINE(LEN:LEN) = ' '
               LEN = LEN + 1
            ENDIF
         ENDIF
         GO TO 10
      ENDIF
C
C --- END OF DO WHILE
C
      RETURN
900   FORMAT ( A80 )
      END
C
C---END GETLIN
C
